package com.ysu.zyw.tool;

import java.io.Serializable;

public class Tuple<K, V> implements Serializable {

    private static final long serialVersionUID = 939236910924147270L;

    private K firstValue;
    private V secondValue;

    public Tuple(K firstValue, V secondValue) {
        super();
        this.firstValue = firstValue;
        this.secondValue = secondValue;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((firstValue == null) ? 0 : firstValue.hashCode());
        result = prime * result + ((secondValue == null) ? 0 : secondValue.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        @SuppressWarnings("rawtypes")
        Tuple other = (Tuple) obj;
        if (firstValue == null) {
            if (other.firstValue != null)
                return false;
        } else if (!firstValue.equals(other.firstValue))
            return false;
        if (secondValue == null) {
            if (other.secondValue != null)
                return false;
        } else if (!secondValue.equals(other.secondValue))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Tuple [firstValue=" + firstValue + ", secondValue=" + secondValue + "]";
    }

    public K getFirstValue() {
        return firstValue;
    }

    public void setFirstValue(K firstValue) {
        this.firstValue = firstValue;
    }

    public V getSecondValue() {
        return secondValue;
    }

    public void setSecondValue(V secondValue) {
        this.secondValue = secondValue;
    }

}
